{include file="public/header-static"/}
{include file="public/sidebar"/}
<style>
    .app-block .app-content .app-action{
        margin-bottom: 0;
    }
</style>
<div id="main">
    {include file="public/header"/}
    <main class="main-content" >
        <div class="container">
            {include file="public/page-header"/}
            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="app-block">
                                <div class="app-content">
                                    <div class="app-action">
                                        <?php if(!isset($rightBtn['add'])?'':$rightBtn['add']){ ?>
                                        <div class="action-left">
                                            <ul class="list-inline">
                                                <li class="list-inline-item mb-0">
                                                    <a href="javascript:void(0);" onclick="add()" class="btn btn-secondary ">
                                                        <i data-feather="plus" class="mr-2"></i>
                                                        {$rightBtn['add']}
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                        <?php } ?>
<!--                                        <div class="action-right">-->
<!--                                            <form class="d-flex mr-3" method="get" action="">-->
<!--                                                <a href="#" class="app-sidebar-menu-button btn btn-outline-light">-->
<!--                                                    <i data-feather="menu"></i>-->
<!--                                                </a>-->
<!--                                                <div class="input-group">-->
<!--                                                    <input type="text" name="keyname" id="keyname" autofocus="autofocus" value="{$Request.get.keyname}"  class="form-control" placeholder="搜索关键字[登录名|昵称|邮箱|手机号]"-->
<!--                                                           aria-describedby="button-addon1">-->
<!--                                                    <div class="input-group-append">-->
<!--                                                        <button class="btn btn-outline-light" type="submit" id="button-addon1">-->
<!--                                                            <i data-feather="search"></i>-->
<!--                                                        </button>-->
<!--                                                    </div>-->
<!--                                                </div>-->
<!--                                            </form>-->
<!--                                        </div>-->
                                    </div>
                                </div>
                            </div>
                            <div>
                                <table id="kplphptable" lay-filter="test"></table>

<!--                                <table id="kplphptable" class="table  table-striped table-bordered">-->
<!--                                    <thead class="thead-dark">-->
<!--                                    <tr>-->
<!--                                        {volist name="fieldsTitle" id="fieldsTitle"}-->
<!--                                        &lt;!&ndash;处理操作按钮&ndash;&gt;-->
<!--                                        <th>{$fieldsTitle}</th>-->
<!--                                        {/volist}-->
<!--                                    </tr>-->
<!--                                    </thead>-->
<!--                                </table>-->
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </main>
    {include file="public/footer"/}
</div>


<!-- DataTable -->
<script src="__STATIC__/vendors/dataTable/jquery.dataTables.min.js"></script>
<script src="__STATIC__/vendors/dataTable/dataTables.bootstrap4.min.js"></script>
<script src="__STATIC__/vendors/dataTable/dataTables.responsive.min.js"></script>
<script src="__STATIC__/assets/js/custom.js"></script>

<script>
    function add() {
        window.location.href = '{:url($kplurl["add"])}';
    }
    function see(id) {
        window.location.href = '{:url($kplurl["see"])}?id='+id;
    }
    function edit(id) {
        window.location.href = '{:url($kplurl["edit"])}?id='+id;
    }
    function del(id,that) {
        $.post('{:url($kplurl["del"])}', {id:id}, function(data) {
            if(data['code']!=1)
            {
                toastr.error(data['msg']);
            }else{
                $(that).parents('tr.even').remove();
                toastr.success(data['msg']);
                setInterval(function () {
                    window.location.href = '';
                },1000);
            }
        });
    }
    function fieldchange(id,field='status')
    {
        $.post("{:url('/power/fieldchange')}",{id:id,field:field},function(){});
    }

    $(document).ready(function () {
        var param = {};
        param.keyname = $.trim($("#keyname").val());//额外传参数k,lko]]]]]
        var columns = [];
        {volist name="fieldsValue"  id="fieldsValue"}
        {if $fieldsValue!='rightbtn'}
            columns[{$key}] = { data: "{$fieldsValue}"};
        {else /}
            columns[{$key}] = {
                data: 'rightbtn', render: function (data,type,row,meta) {
                    var asbtn0 = "<?php echo $rightBtn['see'] = !isset($rightBtn['see'])?'':$rightBtn['see']; ?>";
                    var asbtn1 = "<?php echo $rightBtn['edit'] = !isset($rightBtn['edit'])?'':$rightBtn['edit']; ?>";
                    var asbtn2 = "<?php echo $rightBtn['del'] = !isset($rightBtn['del'])?'':$rightBtn['del']; ?>";
                    var btn = '';
                    var btn0 = '<button type="button" onclick="see('+row['id']+')" title="{$rightBtn[\'see\']}" data-toggle="tooltip" data-placement="top" class="btn btn-sm btn-outline-secondary"><i class="ti-eye mr-2"></i>';
                    var btn1 = '<button type="button" onclick="edit('+row['id']+')" title="{$rightBtn[\'edit\']}" data-toggle="tooltip" data-placement="top" class="btn btn-sm btn-outline-secondary"><i class="ti-settings mr-2"></i>';
                    var btn2 = '<button type="button" onclick="del('+row['id']+',this)" title="{$rightBtn[\'del\']}" data-toggle="tooltip" data-placement="top" class="btn btn-sm btn-outline-secondary"><i class="ti-trash mr-2"></i>';
                    if (asbtn0) {
                        btn += btn0+"{$rightBtn['see']}</button> ";
                    }
                    if (asbtn1) {
                        btn += btn1+"{$rightBtn['edit']}</button> ";
                    }
                    if (asbtn2) {
                        btn += btn2+"{$rightBtn['del']}</button>";
                    }
                    return btn;
                }
            }
        {/if}
        {/volist}
        datatables.dt("#kplphptable","{:url($kplurl['index'])}",columns,param);
    });
</script>

<!-- Prism -->
<script src="__STATIC__/vendors/prism/prism.js"></script>

<!-- App scripts -->
<script src="__STATIC__/assets/js/app.min.js"></script>